#!/bin/bash
targetpath='/usr/java/sell-service'
sourcepath='/usr/java/git/sell-commodity'

SELLCOMMODITY=$(cat /var/run/sell-commodity.pid)
kill $SELLCOMMODITY
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:kill:jar--------------------------------------'
echo '--------------------------------------------------------------------------'
cp -f ${sourcepath}/service/target/sell-commodity.jar ${targetpath}/sell-commodity/sell-commodity.jar
echo '--------------------------------------------------------------------------'
echo '-------------------finished:cp:jar----------------------------------------'
echo '--------------------------------------------------------------------------'

cp -f ${sourcepath}/web/target/sell-commodity.war ${targetpath}/sell-tomcat/webapps/sellcommodity.war
echo '--------------------------------------------------------------------------'
echo '-------------------finished:cp:war----------------------------------------'
echo '--------------------------------------------------------------------------'

JAVA_OPTS="-Xms128m -Xmx256m"
java $JAVA_OPTS -jar ${targetpath}/sell-commodity/sell-commodity.jar test >/dev/null &
echo $! > /var/run/sell-commodity.pid
echo '--------------------------------------------------------------------------'
echo '-------------------finished:run:jar---------------------------------------'
echo '--------------------------------------------------------------------------'

wait
echo "All is ok"
exit 0